package R

import (
	"errors"
	"strings"
)

var (
	InsertExistError = errors.New("E11000 duplicate key error")
	WriteBrokenError = errors.New("broken pipe")
)

func IsEqual(err error, target error) bool {
	if err != nil && target != nil {
		return err.Error() == target.Error()
	}
	return false
}

func IsContain(err interface{}, target error) bool {
	if err != nil && target != nil {
		var origin string
		switch err.(type) {
		case string:
			origin = err.(string)
		case error:
			origin = err.(error).Error()
		}

		return strings.Contains(origin, target.Error())
	}
	return false
}
